import {Login} from "../../api/login.js";

const state = {
    // 本地存储菜单栏状态
    // isCollapse: Cookie.get('isCollapse') ? JSON.parse(Cookie.get('isCollapse')) : false,
    isCollapse: JSON.parse(sessionStorage.getItem('isCollapse')) || false
}
const mutations = {
    SET_ISCOLLAPSE(state) {
        console.log('login');
        state.isCollapse = !state.isCollapse
        // Cookie.set('isCollapse',JSON.stringify(state.isCollapse))
        sessionStorage.setItem('isCollapse', JSON.stringify(state.isCollapse))
    }
}
const getters = {}
const actions = {
    LOGIN(context, requestData) {
        return new Promise((resolve, reject) => {
            Login(requestData)
                .then(response => {
                    resolve(response)
                })
                .catch(error => {
                    reject(error)
                });
        })
    }
}

export default {
    namespaced:true,
    state,
    mutations,
    getters,
    actions
}